package list;

import java.util.*;

public class ListSort {
    public static void main(String[] args) {
        List<Map<String, Integer>> list = new ArrayList<>();
        for (int i = 0; i < 6; i++) {
            Map<String, Integer> map = new HashMap<>();
            map.put("flag", (int) (Math.random() * 5));
            list.add(map);
        }
        // 排序
        list.sort(new Comparator<Map<String, Integer>>() {
            @Override
            public int compare(Map<String, Integer> o1, Map<String, Integer> o2) {
                return o1.get("flag").compareTo(o2.get("flag"));
            }
        });

        Collections.sort(list, new Comparator<Map<String, Integer>>() {
            @Override
            public int compare(Map<String, Integer> o1, Map<String, Integer> o2) {
                return 0;
            }
        });

        List<Date> dates = new ArrayList<>();
        Calendar calendar = Calendar.getInstance();
        for (int i = 0; i < 5; i++) {

            calendar.add(Calendar.HOUR, ((int) Math.random() * 1000) - i);
            dates.add(calendar.getTime());
        }

        // 小 -> 大
        Collections.sort(dates);

        System.out.println(dates);
        System.out.println(list);
    }
}
